{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# COMPSCI 389: Homework 1\n", "\n", "**Assigned**: February 18, 2025. **Due**: February 27, 2025 at 2:00pm Eastern. **Note**: Submissions received after 2:00pm Eastern on March 6, 2025 will receive no credit.\n", "\n", "**Submitting**: Upload your submission on Gradescope as a `.pdf`. Converting to a PDF can be a complicated process, and so we encourage you to test this process well in advance of the submission deadlines. We recommend converting to HTML, opening the HTML file in a browser, and then printing or exporting to a PDF from your browser. We do not recommend directly converting to a PDF, since this requires installing xelatex. To convert to HTML in VSCode, press `ctrl+shift+p` and type `export`, and you should see an option to export to HTML.\n", "\n", "**Note**: Keep your `.ipynb` file, as we may request it directly (via email).\n", "\n", "**Note**: When converting to a PDF file, ensure that all of your code cells have been executed. The results of these executions *must* be included in your submitted PDF." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Instructions\n", "\n", "Complete the questions below, replacing the blue text with your own answers (your answers do not need to remain in blue). Do **not** modify the green text. Try to answer the questions without consulting your notes or any online material. If you cannot, then consult your notes, and if absolutely necessary, consult course materials (slides, notebooks) and/or Wikipedia. Do **not** use other sources or tools like ChatGPT. Complete this part of the assignment on your own (do **not** work with others).\n", "\n", "After you have completed all of the questions, at the bottom of this assignment you will find a link to another notebook, `Homework 1 Solutions.ipynb`. This contains the solutions, and instructions for ensuring that your answers are correct and sufficient. Make another pass through your homework assignment, replacing the green text with descriptions of what you missed for each question, and providing the fixes necessary to make your answer correct. **The solutions file may include additional instructions, which may include additional content to respond to even if you got a question correct (e.g., additional reflection).** During this second stage where you are filling in your answers, replacing the green text, you may reference the solutions, work with others, and use any tools (including ChatGPT).\n", "\n", "You will only submit this assignment once after replacing both the blue and green text. You do not need to submit the assignment between the first and second passes. Grading for each question will be based on whether you followed this process, and arrived at the correct answers and have sufficient discussion/text in the end. Points will be deducted if you did not make a reasonable effort to answer the question initially, if your final answer remains incorrect, of if your answers were not sufficiently clear (so, write in full sentences with proper punctuation, and conveying your arguments clearly). Other than verifying that you made a reasonable initial effort for your initial answers (blue), points will **not** be deducted due to *initial* answers being incorrect. Hence, there is no reason to break the rules to obtain correct answers initially." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Part 1: Short Answer\n", "\n", "Answer the following questions with at least a few sentences, and no more than roughly one page of text." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### 1. [10 points] What is the definition of machine learning?\n", "\n", "***Initial Answer***\n", "\n", "Replace this text with your answer.\n", "\n", "---\n", "\n", "***Updated Answer***\n", "\n", "Replace this text with your response to the solution document.\n", "\n", "---" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### 2. [10 points] What is the difference between regression and classification?\n", "\n", "***Initial Answer***\n", "\n", "Replace this text with your answer.\n", "\n", "---\n", "\n", "***Updated Answer***\n", "\n", "Replace this text with your response to the solution document.\n", "\n", "---" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### 3. [10 points] Give an example of an algorithm (hypothetical or real) that falls within the field of *artificial intelligence* (AI) but **not** the field of *machine learning* (ML). Explain why this algorithm is in an AI algorithm but not an ML algorithm.\n", "\n", "***Initial Answer***\n", "\n", "Replace this text with your answer.\n", "\n", "---\n", "\n", "***Updated Answer***\n", "\n", "Replace this text with your response to the solution document.\n", "\n", "---" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### 4. [10 points] Give an example of a problem that is (or could be) solved using supervised learning. \n", "\n", "Select a problem that we have **not** discussed in class.\n", "\n", "Describe the problem, what the data would look like, whether data is available (or obtainable by some organization), whether it is a classification (binary or multi-class?) or regression problem (univariate or multivariate?). When describing the features that would likely be in the data set, describe whether they are numerical (discrete [binary, non-ninary], continuous), categorical (nominal, ordinal), or of some other type.\n", "\n", "***Initial Answer***\n", "\n", "Replace this text with your answer.\n", "\n", "---\n", "\n", "***Updated Answer***\n", "\n", "Replace this text with your response to the solution document.\n", "\n", "---" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### 5. [10 points] Why should we avoid evaluating machine learning models using the same data that was used to train the model?\n", "\n", "***Initial Answer***\n", "\n", "Replace this text with your answer.\n", "\n", "---\n", "\n", "***Updated Answer***\n", "\n", "Replace this text with your response to the solution document.\n", "\n", "---" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### 6. [10 points] Propose a new (not discussed in class) evaluation metric for regression.\n", "\n", "Give an equation for the new metric, and explain what it does. Does it have potential benefits for some problems? Does it have potential drawbacks?\n", "\n", "**Hint**: If you're stuck, look at the comment in the source of the markdown cell at the bottom of this document. You can do this during the initial answer phase.\n", "\n", "**Note**: If you are unsure how to format your answer using LaTeX to write it in this document, you may consult online references for LaTeX (or use ChatGPT to ask it how to write your equation), but limit this to determining how to display an equation you have already formulated.\n", "\n", "As a reminder, we have already discussed the following metrics:\n", "\n", "Means Squared Error: \n", "$$\\operatorname{MSE}=\\frac{1}{n}\\sum_{i=1}^n (y_i-\\hat y_i)^2,$$\n", "\n", "Root Mean Squared Error:\n", "$$\\operatorname{RMSE}=\\sqrt{\\frac{1}{n}\\sum_{i=1}^n (y_i-\\hat y_i)^2}.$$\n", "\n", "Mean Absolute Error:\n", "$$\\operatorname{MAE}=\\frac{1}{n}\\sum_{i=1}^n \\left \\vert y_i - \\hat y_i \\right \\vert.$$\n", "\n", "R-squared: \n", "$$R^2=1-\\frac{\\sum_{i=1}^n (y_i-\\hat y_i)^2}{\\sum_{i=1}^n (y_i - \\bar y)^2}.$$\n", "\n", "***Initial Answer***\n", "\n", "Replace this text with your answer.\n", "\n", "---\n", "\n", "***Updated Answer***\n", "\n", "Replace this text with your response to the solution document.\n", "\n", "---" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Part 2: Programming\n", "\n", "Recall how we used the function `fetch_openml` from scikit-learn to load OpenML data sets. Below is the code to load the Adult data set, described on OpenML's page [here](https://www.openml.org/search?type=data&status=active&id=45068)." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | age | \n", "workclass | \n", "fnlwgt | \n", "education | \n", "education-num | \n", "marital-status | \n", "occupation | \n", "relationship | \n", "race | \n", "sex | \n", "capital-gain | \n", "capital-loss | \n", "hours-per-week | \n", "native-country | \n", "income | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "25 | \n", "Private | \n", "226802 | \n", "11th | \n", "7 | \n", "Never-married | \n", "Machine-op-inspct | \n", "Own-child | \n", "Black | \n", "Male | \n", "0 | \n", "0 | \n", "40 | \n", "United-States | \n", "<=50K | \n", "
1 | \n", "38 | \n", "Private | \n", "89814 | \n", "HS-grad | \n", "9 | \n", "Married-civ-spouse | \n", "Farming-fishing | \n", "Husband | \n", "White | \n", "Male | \n", "0 | \n", "0 | \n", "50 | \n", "United-States | \n", "<=50K | \n", "
2 | \n", "28 | \n", "Local-gov | \n", "336951 | \n", "Assoc-acdm | \n", "12 | \n", "Married-civ-spouse | \n", "Protective-serv | \n", "Husband | \n", "White | \n", "Male | \n", "0 | \n", "0 | \n", "40 | \n", "United-States | \n", ">50K | \n", "
3 | \n", "44 | \n", "Private | \n", "160323 | \n", "Some-college | \n", "10 | \n", "Married-civ-spouse | \n", "Machine-op-inspct | \n", "Husband | \n", "Black | \n", "Male | \n", "7688 | \n", "0 | \n", "40 | \n", "United-States | \n", ">50K | \n", "
4 | \n", "18 | \n", "NaN | \n", "103497 | \n", "Some-college | \n", "10 | \n", "Never-married | \n", "NaN | \n", "Own-child | \n", "White | \n", "Female | \n", "0 | \n", "0 | \n", "30 | \n", "United-States | \n", "<=50K | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
48837 | \n", "27 | \n", "Private | \n", "257302 | \n", "Assoc-acdm | \n", "12 | \n", "Married-civ-spouse | \n", "Tech-support | \n", "Wife | \n", "White | \n", "Female | \n", "0 | \n", "0 | \n", "38 | \n", "United-States | \n", "<=50K | \n", "
48838 | \n", "40 | \n", "Private | \n", "154374 | \n", "HS-grad | \n", "9 | \n", "Married-civ-spouse | \n", "Machine-op-inspct | \n", "Husband | \n", "White | \n", "Male | \n", "0 | \n", "0 | \n", "40 | \n", "United-States | \n", ">50K | \n", "
48839 | \n", "58 | \n", "Private | \n", "151910 | \n", "HS-grad | \n", "9 | \n", "Widowed | \n", "Adm-clerical | \n", "Unmarried | \n", "White | \n", "Female | \n", "0 | \n", "0 | \n", "40 | \n", "United-States | \n", "<=50K | \n", "
48840 | \n", "22 | \n", "Private | \n", "201490 | \n", "HS-grad | \n", "9 | \n", "Never-married | \n", "Adm-clerical | \n", "Own-child | \n", "White | \n", "Male | \n", "0 | \n", "0 | \n", "20 | \n", "United-States | \n", "<=50K | \n", "
48841 | \n", "52 | \n", "Self-emp-inc | \n", "287927 | \n", "HS-grad | \n", "9 | \n", "Married-civ-spouse | \n", "Exec-managerial | \n", "Wife | \n", "White | \n", "Female | \n", "15024 | \n", "0 | \n", "40 | \n", "United-States | \n", ">50K | \n", "
48842 rows × 15 columns
\n", "